﻿
// ProgramView.h: CProgramView 类的接口
//

#pragma once
#include "BCGL/GUI.h"
#include "BCGL/Object3D.h"

class CProgramView : public CView
{
protected: // 仅从序列化创建
	CProgramView() noexcept;
	DECLARE_DYNCREATE(CProgramView)

	// 特性
public:
	CProgramDoc* GetDocument() const;

	// 操作
public:
private:
	void OffsetClientRect(CDC*);//校正客户区窗口矩形
	void OffsetScreenPoint(CPoint&);//矫正输入窗口坐标
	void DoubleBuffer(CDC*);//双缓冲绘图
	void SingleBuffer(CDC*);//单缓冲绘图
protected:
	CRect rect;//客户区窗口矩形
	CProjection mainCamera;//投影对象：主相机
	CLighting light;//光照对象
	CGUI ui;//GUI对象
	CObject3D obj;//3D对象
	CZBuffer* zBuffer;//深度缓冲器
protected://测试
	CTransform3 t;
protected:
	SIGN doubleBufferModeOn = true;//双缓冲开关
	SIGN cameraRotateAvtive = false;//鼠标旋转相机控制标记
	SIGN leftButtonDown = false;//鼠标左键按下标记
	SIGN CtrlButtonPressed = false;
	SIGN mouseOnMoveButton = false;
	MODE cameraMoveAvtive = false;//鼠标移动相机控制标记
	MODE renderMode = FrameMode, lastMode = FrameMode;//着色模式
	CP2 begin, end;//选择区域
	CPoint lastMousePoint;//上一帧鼠标位置
	// 重写
public:
	virtual void OnDraw(CDC* pDC);  // 重写以绘制该视图
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:

	// 实现
public:
	virtual ~CProgramView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

	// 生成的消息映射函数
protected:
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
	afx_msg void OnObjExport();
	afx_msg void OnModeFrame();
	afx_msg void OnModeVisibleFrame();
	afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
	//	afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnModeDefault();
	afx_msg void OnModeTexturePhong();
	afx_msg void OnModeVertex();
	afx_msg void OnBufferSingle();
	afx_msg void OnBufferDouble();
	afx_msg void OnModeNormal();
//	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnShadingTransmission();
};

#ifndef _DEBUG  // ProgramView.cpp 中的调试版本
inline CProgramDoc* CProgramView::GetDocument() const
{
	return reinterpret_cast<CProgramDoc*>(m_pDocument);
}
#endif

